layui.use(['layer', 'form', 'admin', 'laydate', 'ax', 'formSelects','upload'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var upload = layui.upload;
    var laydate = layui.laydate;
    
    laydate.render({
        elem: '#test2'
        ,type: 'datetime'
     });
    
    laydate.render({
        elem: '#test3'
        ,type: 'datetime'
      });
    
    // 表单提交事件
    form.on('submit(btnSubmit)', function (data) {
    	var startTime = $("#test2").val();
    	var endTime = $("#test3").val();
    	var listsId = $("#listsId").val();
    	var data = {
    			listsId: listsId,
    			startTime: startTime,
    			endTime: endTime,
    			listStatus:1
    	}
    	// 异步请求
    	$.ajax({
    		url: Feng.ctxPath + "/modular/lists/update",
    		data: JSON.stringify(data),
    		type: "post",
    		contentType: "application/json;charset=UTF-8",
    		async: false,//关闭异步请求
    		dataType: "json",
    		success: function (data) {
    			if (data.code == 200) {
    				Feng.success("操作成功！");
    				//传给上个页面，刷新table用
    				window.parent.location.reload();
    				 var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
    			     parent.layer.close(index);
    			} else {
    				Feng.success("操作失败！" + data.message);
    			}
    		}
    	,
    	error: function (data) {
    		Feng.error("添加失败！" + data.message)
    	}
    	});
    });
    
});
